package com.learn.springlearn.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
@Aspect
@Slf4j
public class LogAspectJ {


    @Pointcut("execution(* com.learn.springlearn.controller.*.*(..))")
    public void pointcut(){

    }

    @Before("pointcut()")
    public void before(JoinPoint joinPoint){
        Signature signature = joinPoint.getSignature();
//        System.out.println("进入到了切面");
    }

    @After("pointcut()")
    public void after(JoinPoint joinPoint){
        Signature signature = joinPoint.getSignature();
//        System.out.println("进入到了切面");
    }


    @AfterThrowing(throwing = "e",pointcut = "pointcut()")
    public void throwException(Exception e){
        log.error("切面捕获到了异常",e);
    }




}
